#!/bin/bash

# Beeps if battery load below MINC (and not charging).
# Nags if load below NAGC (and not charging).
# Alerts gently if battery load above MAXC (and charging).
# To be run from crontab each minute. Needs mplayer.

MINC=10
NAGC=7
MAXC=90

charging_status=$( acpi | awk '{print $3}' | sed 's/,//' )
bat=$( acpi | awk '{print $4}' | sed 's/,//' )
batnum=${bat/\%/}

if [ $charging_status == 'Discharging' ] ; then
   if [ $batnum -lt  $MINC ] ; then
      mplayer -really-quiet -nolirc $HOME/sounds/S_Knock.ogg & 
      if [ $batnum -lt $NAGC ] ; then
         mplayer -really-quiet -nolirc $HOME/sounds/Beep_beep.ogg &
      fi
   fi
else
   if [ $batnum -gt $MAXC ] ; then
      mplayer -really-quiet -nolirc $HOME/sounds/Antares.ogg &
   fi
fi

#logger "$0 done."

# vim:tw=0
